import DList from "@/components/dlist";
export default {
  data() {
    return {
      loading: false,
      finished: false,
      page: 1,
      logList: []
    };
  },
  mounted() {
    this.getPackageLog();
  },
  methods: {
    async getPackageLog() {
      if (this.loading === true || this.finished === true) {
        return;
      }
      this.loading = true;
      let { data, result, msg } = await $http.get("plugin.be-within-call.frontend.enterprise.package-log", { page: this.page});
      if (result === 0) {
        this.$toast(msg);
        return;
      }
      if (data.data.length === 0 || data.data.length < data.per_page || data.current_page === data.last_page) {
        this.finished = true;
      }
      this.total = data.total;
      this.logList.push(...data.data);
      this.page++;
      this.loading = false;
    },
    onLoad() {
      this.getPackageLog();
    },
  },
  components: { DList }
};
